********************************************************************************
** Replication of Analysis  
** Do file to produce tables and figures for 
** "Inferring Tax Compliance from Pass-Through: Evidence from Airbnb Tax Enforcement Agreements"
** By Andrew Bibler, Keith Teltser, and Mark Tremblay
********************************************************************************

clear all
set more off

use propmonth_analysis_restricted.dta , clear

drop if regexm(metro, ".*Anchorage") 
drop if regexm(metro, ".*Atlanta")
drop if regexm(metro, ".*Austin")
drop if regexm(metro, ".*Boston")
drop if regexm(metro, ".*Charlotte")
drop if regexm(metro, ".*Dallas")
drop if regexm(metro, ".*Houston")
drop if regexm(metro, ".*Indianapolis")
drop if regexm(metro, ".*Minneapolis")
drop if regexm(metro, ".*Nashville")
drop if regexm(metro, ".*Philadelphia")

** listing type
gen entirehome = regexm(listingtype , ".*Entire") 

replace numbookings=0 if numbookings==.

******************************************************************************************
*********************** Summary Statistics Tables ****************************************
******************************************************************************************

** TABLE 1, PANEL A

*** Property-Month level summary stats (the current unit of observation)

qui reg booked bookprice

** store vector of means
su bookprice
estadd scalar price = r(mean)

su booked
estadd scalar book = r(mean)

su taxrate
estadd scalar tax = r(mean)

su askingprice 
estadd scalar ask = r(mean)

su supply 
estadd scalar sup = r(mean)

est store A

** store vector of sds
qui reg booked bookprice

su bookprice
estadd scalar price = r(sd)

su booked
estadd scalar book = r(sd)

su taxrate
estadd scalar tax = r(sd)

su askingprice 
estadd scalar ask = r(sd)

su supply 
estadd scalar sup = r(sd)

est store B

** store vector of 25th percentile
qui reg booked bookprice

su bookprice , detail
estadd scalar price = r(p25)

su booked , detail
estadd scalar book = r(p25)

su taxrate , detail
estadd scalar tax = r(p25)

su askingprice , detail
estadd scalar ask = r(p25)

su supply , detail
estadd scalar sup = r(p25)

est store C

** store vector of medians
qui reg booked bookprice

su bookprice , detail
estadd scalar price = r(p50)

su booked , detail
estadd scalar book = r(p50)

su taxrate , detail
estadd scalar tax = r(p50)

su askingprice , detail 
estadd scalar ask = r(p50)

su supply , detail
estadd scalar sup = r(p50)

est store med

** store vector of 75th percentile
qui reg booked bookprice

su bookprice , detail
estadd scalar price = r(p75)

su booked , detail
estadd scalar book = r(p75)

su taxrate , detail
estadd scalar tax = r(p75)

su askingprice , detail 
estadd scalar ask = r(p75)

su supply , detail
estadd scalar sup = r(p75)

est store D

** store vector of Obs
qui reg booked bookprice

su bookprice
estadd scalar price = r(N)

su booked
estadd scalar book = r(N)

su taxrate
estadd scalar tax = r(N)

su askingprice 
estadd scalar ask = r(N)

su supply 
estadd scalar sup = r(N)

est store E

esttab A B C med D E using Table1A.tex , replace ///
mtitles("Mean" "St. Dev." "25th pctl" "Median" "75th pct" "Obs") ///
label booktabs nonum gaps noobs f collabels(none) cells(none) ///
stats(price book tax ask sup , fmt(%10.2f %10.2f %10.2f %10.2f %10.2f) layout("\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}") labels(`"Booking Price"' `"Days Booked / Month"' `"Tax Rate"' `"Asking Price"' `"Nights Avail."'))



** TABLE 1, PANEL B 

bysort propertyid: gen propobs = _n==1

** means
qui reg booked bookprice 

su bedrooms if propobs==1
estadd scalar br = r(mean)

su bathrooms if propobs==1
estadd scalar ba = r(mean)

su maxguests if propobs==1
estadd scalar max = r(mean)

su entirehome if propobs==1
estadd scalar entire = r(mean)

su overallrating if propobs==1
estadd scalar rate = r(mean)

su securitydeposit if propobs==1
estadd scalar sec = r(mean)

su cleaningfee if propobs==1
estadd scalar clean = r(mean)

su extrapeoplefee if propobs==1
estadd scalar extra = r(mean)

su minimumstay if propobs==1
estadd scalar min = r(mean)

su businessready_dum if propobs==1
estadd scalar bus = r(mean)

su superhost_dum if propobs==1
estadd scalar super = r(mean)

su numberofphotos if propobs==1
estadd scalar photos = r(mean)

est store A

** sds
qui reg booked bookprice 

su bedrooms if propobs==1
estadd scalar br = r(sd)

su bathrooms if propobs==1
estadd scalar ba = r(sd)

su maxguests if propobs==1
estadd scalar max = r(sd)

su entirehome if propobs==1
estadd scalar entire = r(sd)

su overallrating if propobs==1
estadd scalar rate = r(sd)

su securitydeposit if propobs==1
estadd scalar sec = r(sd)

su cleaningfee if propobs==1
estadd scalar clean = r(sd)

su extrapeoplefee if propobs==1
estadd scalar extra = r(sd)

su minimumstay if propobs==1
estadd scalar min = r(sd)

su businessready_dum if propobs==1
estadd scalar bus = r(sd)

su superhost_dum if propobs==1
estadd scalar super = r(sd)

su numberofphotos if propobs==1
estadd scalar photos = r(sd)

est store B

** 25th percentile
qui reg booked bookprice 

su bedrooms if propobs==1 , detail
estadd scalar br = r(p25)

su bathrooms if propobs==1  , detail
estadd scalar ba = r(p25)

su maxguests if propobs==1  , detail
estadd scalar max = r(p25)

su entirehome if propobs==1  , detail
estadd scalar entire = r(p25)

su overallrating if propobs==1  , detail
estadd scalar rate = r(p25)

su securitydeposit if propobs==1  , detail
estadd scalar sec = r(p25)

su cleaningfee if propobs==1  , detail
estadd scalar clean = r(p25)

su extrapeoplefee if propobs==1  , detail
estadd scalar extra = r(p25)

su minimumstay if propobs==1  , detail
estadd scalar min = r(p25)

su businessready_dum if propobs==1  , detail
estadd scalar bus = r(p25)

su superhost_dum if propobs==1  , detail
estadd scalar super = r(p25)

su numberofphotos if propobs==1 , detail
estadd scalar photos = r(p25)

est store C

** median
qui reg booked bookprice 

su bedrooms if propobs==1 , detail
estadd scalar br = r(p50)

su bathrooms if propobs==1  , detail
estadd scalar ba = r(p50)

su maxguests if propobs==1  , detail
estadd scalar max = r(p50)

su entirehome if propobs==1  , detail
estadd scalar entire = r(p50)

su overallrating if propobs==1  , detail
estadd scalar rate = r(p50)

su securitydeposit if propobs==1  , detail
estadd scalar sec = r(p50)

su cleaningfee if propobs==1  , detail
estadd scalar clean = r(p50)

su extrapeoplefee if propobs==1  , detail
estadd scalar extra = r(p50)

su minimumstay if propobs==1  , detail
estadd scalar min = r(p50)

su businessready_dum if propobs==1  , detail
estadd scalar bus = r(p50)

su superhost_dum if propobs==1  , detail
estadd scalar super = r(p50)

su numberofphotos if propobs==1 , detail
estadd scalar photos = r(p50)

est store med

** 75th percentile
qui reg booked bookprice 

su bedrooms if propobs==1 , detail
estadd scalar br = r(p75)

su bathrooms if propobs==1 , detail
estadd scalar ba = r(p75)

su maxguests if propobs==1 , detail
estadd scalar max = r(p75)

su entirehome if propobs==1 , detail
estadd scalar entire = r(p75)

su overallrating if propobs==1 , detail
estadd scalar rate = r(p75)

su securitydeposit if propobs==1 , detail
estadd scalar sec = r(p75)

su cleaningfee if propobs==1 , detail
estadd scalar clean = r(p75)

su extrapeoplefee if propobs==1 , detail
estadd scalar extra = r(p75)

su minimumstay if propobs==1 , detail
estadd scalar min = r(p75)

su businessready_dum if propobs==1 , detail
estadd scalar bus = r(p75)

su superhost_dum if propobs==1 , detail
estadd scalar super = r(p75)

su numberofphotos if propobs==1 , detail
estadd scalar photos = r(p75)

est store D

** obs
qui reg booked bookprice 

su bedrooms if propobs==1
estadd scalar br = r(N)

su bathrooms if propobs==1
estadd scalar ba = r(N)

su maxguests if propobs==1
estadd scalar max = r(N)

su entirehome if propobs==1
estadd scalar entire = r(N)

su overallrating if propobs==1
estadd scalar rate = r(N)

su securitydeposit if propobs==1
estadd scalar sec = r(N)

su cleaningfee if propobs==1
estadd scalar clean = r(N)

su extrapeoplefee if propobs==1
estadd scalar extra = r(N)

su minimumstay if propobs==1
estadd scalar min = r(N)

su businessready_dum if propobs==1
estadd scalar bus = r(N)

su superhost_dum if propobs==1
estadd scalar super = r(N)

su numberofphotos if propobs==1
estadd scalar photos = r(N)

est store E

esttab A B C med D E using Table1B.tex , replace ///
mtitles("Mean" "St. Dev." "25th pctl" "Median" "75th pctl" "Obs") ///
label booktabs nonum gaps noobs f collabels(none) cells(none) ///
stats(br ba max entire rate sec clean extra min bus super photos , fmt(%10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f) layout("\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}") labels(`"Bedrooms"' `"Bathrooms"' `"Max Guests"' `"Entire Home/Apt"' `"Rating"' `"Security Deposit"' `"Cleaning Fee"' `"Extra People Fee"' `"Minimum Stay (Days)"' `"Business Ready"' `"Superhost"' `"Number of Photos"'))

******************************************************************************************
***** TABLE 2: Main Estimates Using a dummy treatment instead of dummy X Tax rate *******
******************************************************************************************

gen treat = (lntaxvar>0)

global controls "i.bedrooms i.bathrooms1 i.maxguests1 entirehome i.rated#c.rating1 i.rated#c.rating1sq securitydeposit securitydepositsq cleaningfee cleaningfeesq extrapeoplefee extrapeoplefeesq i.cancel i.minimumstay1 i.hasphotos#c.photos1 i.hasphotos#c.photos1sq i.businessready_dum i.superhost1"

** Panel A (ln booking price)
qui reghdfe lnbookprice treat [w=booked] , absorb(propertyid i.metro1#i.obsym) cluster(taxjuris)
outreg2 using Table2A.xls , excel keep(treat) ct("ln(Booking Price)") replace

qui reghdfe lnbookprice treat [w=booked] , absorb(propertyid i.countyid#i.obsym) cluster(taxjuris)
outreg2 using Table2A.xls , excel keep(treat) ct("ln(Booking Price)") append

qui reghdfe lnbookprice treat [w=booked] , absorb(propertyid i.obsym) cluster(taxjuris)
outreg2 using Table2A.xls , excel keep(treat) ct("ln(Booking Price)") append

qui reghdfe lnbookprice treat $controls [w=booked] , absorb(taxjuris i.metro1#i.obsym) cluster(taxjuris)
outreg2 using Table2A.xls , excel keep(treat) ct("ln(Booking Price)") append

qui reghdfe lnbookprice treat $controls [w=booked] , absorb(taxjuris i.countyid#i.obsym) cluster(taxjuris)
outreg2 using Table2A.xls , excel keep(treat) ct("ln(Booking Price)") append

qui reghdfe lnbookprice treat $controls [w=booked] , absorb(taxjuris i.obsym) cluster(taxjuris)
outreg2 using Table2A.xls , excel keep(treat) ct("ln(Booking Price)") append

** Panel B (log nights booked) 
qui reghdfe lnbooked treat , absorb(propertyid i.metro1#i.obsym) cluster(taxjuris)
outreg2 using Table2B.xls , excel keep(treat) ct("ln(1 + Nights Booked)") replace

qui reghdfe lnbooked treat , absorb(propertyid i.countyid#i.obsym) cluster(taxjuris)
outreg2 using Table2B.xls , excel keep(treat) ct("ln(1 + Nights Booked)") append

qui reghdfe lnbooked treat , absorb(propertyid i.obsym) cluster(taxjuris)
outreg2 using Table2B.xls , excel keep(treat) ct("ln(1 + Nights Booked)") append

qui reghdfe lnbooked treat $controls , absorb(taxjuris i.metro1#i.obsym) cluster(taxjuris)
outreg2 using Table2B.xls , excel keep(treat) ct("ln(1 + Nights Booked)") append

qui reghdfe lnbooked treat $controls , absorb(taxjuris i.countyid#i.obsym) cluster(taxjuris)
outreg2 using Table2B.xls , excel keep(treat) ct("ln(1 + Nights Booked)") append

qui reghdfe lnbooked treat $controls , absorb(taxjuris i.obsym) cluster(taxjuris)
outreg2 using Table2B.xls , excel keep(treat) ct("ln(1 + Nights Booked)") append
  
********************************************************************************
*******     TABLE 3: Main Results: Booking Price and Number Booked     *********
********************************************************************************

** Panel A, Log of Booking Price
qui reghdfe lnbookprice lntaxvar [w=booked] , absorb(propertyid i.metro1#i.obsym) cluster(taxjuris)
outreg2 using Table3A.xls , excel keep(lntaxvar) ct("ln(Booking Price)") replace

qui reghdfe lnbookprice lntaxvar [w=booked] , absorb(propertyid i.countyid#i.obsym) cluster(taxjuris)
outreg2 using Table3A.xls , excel keep(lntaxvar) ct("ln(Booking Price)") append

qui reghdfe lnbookprice lntaxvar [w=booked] , absorb(propertyid i.obsym) cluster(taxjuris)
outreg2 using Table3A.xls , excel keep(lntaxvar) ct("ln(Booking Price)") append

qui reghdfe lnbookprice lntaxvar $controls [w=booked] , absorb(taxjuris i.metro1#i.obsym) cluster(taxjuris)
outreg2 using Table3A.xls , excel keep(lntaxvar) ct("ln(Booking Price)") append

qui reghdfe lnbookprice lntaxvar $controls [w=booked] , absorb(taxjuris i.countyid#i.obsym) cluster(taxjuris)
outreg2 using Table3A.xls , excel keep(lntaxvar) ct("ln(Booking Price)") append

qui reghdfe lnbookprice lntaxvar $controls [w=booked] , absorb(taxjuris i.obsym) cluster(taxjuris)
outreg2 using Table3A.xls , excel keep(lntaxvar) ct("ln(Booking Price)") append

** Panel B, log nights booked
qui reghdfe lnbooked lntaxvar , absorb(propertyid i.metro1#i.obsym) cluster(taxjuris)
outreg2 using Table3B.xls , excel keep(lntaxvar) ct("ln(1 + Nights Booked)") replace

qui reghdfe lnbooked lntaxvar , absorb(propertyid i.countyid#i.obsym) cluster(taxjuris)
outreg2 using Table3B.xls , excel keep(lntaxvar) ct("ln(1 + Nights Booked)") append

qui reghdfe lnbooked lntaxvar , absorb(propertyid i.obsym) cluster(taxjuris)
outreg2 using Table3B.xls , excel keep(lntaxvar) ct("ln(1 + Nights Booked)") append

qui reghdfe lnbooked lntaxvar $controls , absorb(taxjuris i.metro1#i.obsym) cluster(taxjuris)
outreg2 using Table3B.xls , excel keep(lntaxvar) ct("ln(1 + Nights Booked)") append

qui reghdfe lnbooked lntaxvar $controls , absorb(taxjuris i.countyid#i.obsym) cluster(taxjuris)
outreg2 using Table3B.xls , excel keep(lntaxvar) ct("ln(1 + Nights Booked)") append

qui reghdfe lnbooked lntaxvar $controls , absorb(taxjuris i.obsym) cluster(taxjuris)
outreg2 using Table3B.xls , excel keep(lntaxvar) ct("ln(1 + Nights Booked)") append

*************
** Table 4 **
*************
** supply response estimates

gen entrysample = 1
replace entrysample=0 if inlist(obsym,655,692)

bysort propertyid: egen lastsupply = max(obsym) if supply>0
bysort propertyid: egen lastsupply2 = min(lastsupply)
gen firstzero = lastsupply2 + 1
gen exit2 = 0
replace exit2 = 1 if obsym==lastsupply2 & lastsupply2!=692
replace exit2=. if obsym>lastsupply2 

** asking price
qui reghdfe lnaskingprice lntaxvar , absorb(propertyid i.metro1#i.obsym) cluster(taxjuris)
outreg2 using Table4A.xls , excel keep(lntaxvar) ct("ln(Ask P)") replace

** ln supply
qui reghdfe lnsupply lntaxvar , absorb(propertyid i.metro1#i.obsym) cluster(taxjuris)
outreg2 using Table4A.xls , excel keep(lntaxvar) ct("ln(1 + Nights Available)") append

** Entry
qui reghdfe entry lntaxvar if entrysample==1, absorb(propertyid i.metro1#i.obsym) cluster(taxjuris)
outreg2 using Table4A.xls , excel keep(lntaxvar) ct("Entry") append

** Exit
qui reghdfe exit lntaxvar if entrysample==1 , absorb(propertyid i.metro1#i.obsym) cluster(taxjuris)
outreg2 using Table4A.xls , excel keep(lntaxvar) ct("Exit") append

gen posbook = (booked>0)

bysort taxjuris obsym: egen maxtax = max(taxvar) if metro=="Seattle" 
replace taxvar = maxtax if metro=="Seattle"

collapse (mean) taxvar propexit=exit2 propentry=entry (sum) numexit2=exit2 numexit=exit numentry=entry booked posbook (count) numprops=propertyid , by(taxjuris metro1 countyname obsym entrysample)

gen numnetentry = numentry - numexit

duplicates tag taxjuris , gen(dups)

su dups
keep if dups==r(max)


xtset taxjuris obsym

gen taxdummy = taxvar>0

gen lntaxvar = ln(1 + taxvar)

gen lnnumprops = ln(1 + numprops)

gen lnpropexit = ln(1 + propexit)

gen lnpropentry = ln(1 + propentry)

gen lnnumexit = ln(1 + numexit)

gen lnnumentry = ln(1 + numentry)

bysort taxjuris: gen netentrypct = numnetentry/(numprops[_n-1])

gen lnbooked = ln(1 + booked)

gen lnposbooked = ln(1 + posbook)

gen propbooked = posbook/numprops

sort taxjuris obsym

************** Table of jursdiction level outcomes on ln tax

** Number entry
reghdfe numentry lntaxvar if entrysample==1 , absorb(taxjuris i.obsym#i.metro1) cluster(taxjuris)
outreg2 using Table4B.xls , excel keep(lntaxvar) ct("Number Entry") replace

** Number Exit
reghdfe numexit lntaxvar if entrysample==1 , absorb(taxjuris i.obsym#i.metro1) cluster(taxjuris)
outreg2 using Table4B.xls , excel keep(lntaxvar) ct("Number Exit") append

** Number Net entry
reghdfe numnetentry lntaxvar if entrysample==1 , absorb(taxjuris i.obsym#i.metro1) cluster(taxjuris)
outreg2 using Table4B.xls , excel keep(lntaxvar) ct("Number Net Entry") append

** pct Net entry
reghdfe netentrypct lntaxvar if entrysample==1 , absorb(taxjuris i.obsym#i.metro1) cluster(taxjuris)
outreg2 using Table4B.xls , excel keep(lntaxvar) ct("Pct Net Entry") append

  
 
********************************
** EVEN STUDY FIGURES 
********************************
use propmonth_analysis_restricted.dta , clear

drop if regexm(metro, ".*Anchorage") 
drop if regexm(metro, ".*Atlanta")
drop if regexm(metro, ".*Austin")
drop if regexm(metro, ".*Boston")
drop if regexm(metro, ".*Charlotte")
drop if regexm(metro, ".*Dallas")
drop if regexm(metro, ".*Houston")
drop if regexm(metro, ".*Indianapolis")
drop if regexm(metro, ".*Minneapolis")
drop if regexm(metro, ".*Nashville")
drop if regexm(metro, ".*Philadelphia")

gen entirehome = 0
replace entirehome = 1 if listingtype=="Entire home/apt"

bysort taxjuris: egen avgtaxvar = mean(taxvar)
gen treated = 0
replace treated = 1 if avgtaxvar>0

gen monthofintro = taxintro
drop if monthofintro==689
replace monthofintro = 0 if missing(taxintro)

sort taxjuris propertyid obsym

set seed 12345
gen rand = uniform()
bysort taxjuris : replace monthofintro = 661 if (rand<=1/13) & monthofintro==0 & _n==1
bysort taxjuris : replace monthofintro = 663 if (rand<=2/13 & rand > 1/13) & monthofintro==0 & _n==1
bysort taxjuris : replace monthofintro = 666 if (rand<=3/13 & rand > 2/13) & monthofintro==0 & _n==1
bysort taxjuris : replace monthofintro = 669 if (rand<=4/13 & rand > 3/13) & monthofintro==0 & _n==1
bysort taxjuris : replace monthofintro = 670 if (rand<=5/13 & rand > 4/13) & monthofintro==0 & _n==1
bysort taxjuris : replace monthofintro = 671 if (rand<=6/13 & rand > 5/13) & monthofintro==0 & _n==1
bysort taxjuris : replace monthofintro = 672 if (rand<=7/13 & rand > 6/13) & monthofintro==0 & _n==1
bysort taxjuris : replace monthofintro = 675 if (rand<=8/13 & rand > 7/13) & monthofintro==0 & _n==1
bysort taxjuris : replace monthofintro = 677 if (rand<=9/13 & rand > 8/13) & monthofintro==0 & _n==1
bysort taxjuris : replace monthofintro = 679 if (rand<=10/13 & rand > 9/13) & monthofintro==0 & _n==1
bysort taxjuris : replace monthofintro = 681 if (rand<=11/13 & rand > 10/13) & monthofintro==0 & _n==1
bysort taxjuris : replace monthofintro = 684 if (rand<=12/13 & rand > 11/13) & monthofintro==0 & _n==1
bysort taxjuris : replace monthofintro = 685 if (rand<=13/13 & rand > 12/13) & monthofintro==0 & _n==1

bysort taxjuris : egen intromonth = max(monthofintro)

gen timesinceintro = obsym - intromonth
replace timesinceintro = 7 if timesinceintro>7
drop if timesinceintro < -5

gen recenteredtime = timesinceintro + 6

foreach x of numlist 1/13 {

gen treated`x' = 0
replace treated`x' = treated if recenteredtime==`x'

}

xtset propertyid obsym
global controls "i.bedrooms i.bathrooms1 i.maxguests1 i.entirehome i.rated#c.rating1 i.rated#c.rating1sq securitydeposit securitydepositsq cleaningfee cleaningfeesq extrapeoplefee extrapeoplefeesq i.cancel i.minimumstay1 i.hasphotos#c.photos1 i.hasphotos#c.photos1sq i.businessready_dum i.superhost1"

sort taxjuris propertyid obsym

reghdfe lnbookprice treated1 treated2 treated3 treated4 treated6 treated7 treated8 treated9 treated10 treated11 treated12 treated13, absorb(i.metro1#i.obsym i.propertyid) cluster(taxjuris)

coefplot, keep(treated*) ///
coeflabel(treated1 = "-5" treated2 = "-4" treated3 = "-3" treated4 = "-2" treated5 = "-1" treated6 = "0" treated7 = "1" treated8 = "2" treated9 = "3" treated10 = "4" treated11 = "5" treated12 = "6" treated13 = ">= 7") ///
vertical yline(0) title("Booking Price Event Study")

graph export "Figure2.png", as(png) replace

*exclude -2 instead of -1, pre-treatment spike in bookings
reghdfe lnbooked treated1 treated2 treated3 treated5 treated6 treated7 treated8 treated9 treated10 treated11 treated12 treated13, absorb(i.metro1#i.obsym i.propertyid) cluster(taxjuris)

coefplot, keep(treated*) ///
coeflabel(treated1 = "-5" treated2 = "-4" treated3 = "-3" treated4 = "-2" treated5 = "-1" treated6 = "0" treated7 = "1" treated8 = "2" treated9 = "3" treated10 = "4" treated11 = "5" treated12 = "6" treated13 = ">= 7") ///
vertical yline(0) title("Nights Booked Event Study")

graph export "Figure3.png", as(png) replace
  
  
**************************
*** END OF MAIN ANALYSIS 
**************************  
  
  
******************
** APPENDIX C ****
****************** 
  
******************
** Table C5 ******
******************
** including all juridisctions
use "propmonth_analysis_full.dta" , clear
gen entirehome = regexm(listingtype, ".*Entire")   
  
** Panel A, Log of Booking Price
qui reghdfe lnbookprice lntaxvar [w=booked] , absorb(propertyid i.metro1#i.obsym) cluster(taxjuris)
outreg2 using TableC5A.xls , excel keep(lntaxvar) ct("ln(Booking Price)") replace

qui reghdfe lnbookprice lntaxvar [w=booked] , absorb(propertyid i.countyid#i.obsym) cluster(taxjuris)
outreg2 using TableC5A.xls , excel keep(lntaxvar) ct("ln(Booking Price)") append

qui reghdfe lnbookprice lntaxvar [w=booked] , absorb(propertyid i.obsym) cluster(taxjuris)
outreg2 using TableC5A.xls , excel keep(lntaxvar) ct("ln(Booking Price)") append

qui reghdfe lnbookprice lntaxvar $controls [w=booked] , absorb(taxjuris i.metro1#i.obsym) cluster(taxjuris)
outreg2 using TableC5A.xls , excel keep(lntaxvar) ct("ln(Booking Price)") append

qui reghdfe lnbookprice lntaxvar $controls [w=booked] , absorb(taxjuris i.countyid#i.obsym) cluster(taxjuris)
outreg2 using TableC5A.xls , excel keep(lntaxvar) ct("ln(Booking Price)") append

qui reghdfe lnbookprice lntaxvar $controls [w=booked] , absorb(taxjuris i.obsym) cluster(taxjuris)
outreg2 using TableC5A.xls , excel keep(lntaxvar) ct("ln(Booking Price)") append

** Panel B, log nights booked
qui reghdfe lnbooked lntaxvar , absorb(propertyid i.metro1#i.obsym) cluster(taxjuris)
outreg2 using TableC5B.xls , excel keep(lntaxvar) ct("ln(1 + Nights Booked)") replace

qui reghdfe lnbooked lntaxvar , absorb(propertyid i.countyid#i.obsym) cluster(taxjuris)
outreg2 using TableC5B.xls , excel keep(lntaxvar) ct("ln(1 + Nights Booked)") append

qui reghdfe lnbooked lntaxvar , absorb(propertyid i.obsym) cluster(taxjuris)
outreg2 using TableC5B.xls , excel keep(lntaxvar) ct("ln(1 + Nights Booked)") append

qui reghdfe lnbooked lntaxvar $controls , absorb(taxjuris i.metro1#i.obsym) cluster(taxjuris)
outreg2 using TableC5B.xls , excel keep(lntaxvar) ct("ln(1 + Nights Booked)") append

qui reghdfe lnbooked lntaxvar $controls , absorb(taxjuris i.countyid#i.obsym) cluster(taxjuris)
outreg2 using TableC5B.xls , excel keep(lntaxvar) ct("ln(1 + Nights Booked)") append

qui reghdfe lnbooked lntaxvar $controls , absorb(taxjuris i.obsym) cluster(taxjuris)
outreg2 using TableC5B.xls , excel keep(lntaxvar) ct("ln(1 + Nights Booked)") append
  
  
 
  
******************
** APPENDIX D ****
****************** 
  
  
  
**************  
** TABLE D1 **
**************  
** Testing Pre-Treatment Differences in Observables 
use propmonth_analysis_restricted.dta , clear

drop if regexm(metro, ".*Anchorage") 
drop if regexm(metro, ".*Atlanta")
drop if regexm(metro, ".*Austin")
drop if regexm(metro, ".*Boston")
drop if regexm(metro, ".*Charlotte")
drop if regexm(metro, ".*Dallas")
drop if regexm(metro, ".*Houston")
drop if regexm(metro, ".*Indianapolis")
drop if regexm(metro, ".*Minneapolis")
drop if regexm(metro, ".*Nashville")
drop if regexm(metro, ".*Philadelphia")

** listing type
gen entirehome = regexm(listingtype , ".*Entire") 

replace numbookings=0 if numbookings==.


gen treatedmonth = taxvar>0

bysort taxjuris: egen treatedjuris = max(treatedmonth) 

bysort taxjuris: egen firsttaxmonth = min(obsym) if treatedmonth==1

bysort taxjuris: egen firsttaxmonth2 = min(firsttaxmonth)

gen lninitialtax = lntaxvar if firsttaxmonth==obsym

bysort taxjuris: egen lninitialtax2 = min(lninitialtax)

*********************************************************************
*********** averages and testing differences ************************
*********************************************************************
** the last, first month of treatment is 688 (May '17)
gen presample = (treatedmonth==0 & obsym<688)

local sstats "bookprice lnbookprice booked lnbooked askingprice lnaskingprice"

lab var bookprice "Booking Price"
lab var lnbookprice "Ln(Booking Price)"
lab var booked "Nights Booked / Month"
lab var lnbooked "Ln(Booked / Month)"
lab var askingprice "Asking Price"
lab var lnaskingprice "Ln(Asking Price)"

** Table with non-treatment months only
estpost su `sstats' if presample==1
estadd local taxjurisfe = "-" 
estadd local monthyrfe = "-"
estadd local countymonthyrfe = "-"
estadd local metromonthyrfe = "-"
estadd local propcontrols = "-"
est store C1 

estpost su `sstats' if (presample==1 & treatedjuris==1) 
estadd local taxjurisfe = "-" 
estadd local monthyrfe = "-"
estadd local countymonthyrfe = "-"
estadd local metromonthyrfe = "-"
estadd local propcontrols = "-"
est store C2

estpost su `sstats' if (presample==1 & treatedjuris==0) 
estadd local taxjurisfe = "-" 
estadd local monthyrfe = "-"
estadd local countymonthyrfe = "-"
estadd local metromonthyrfe = "-"
estadd local propcontrols = "-"
est store C3

esttab C1 C2 C3 using TableD1_summary.tex, replace ///
mtitles("Full Sample" "Treated" "Not Treated") ///
cells(mean(fmt(2)) sd(fmt(2)par)) label booktabs nonum collabels(none) gaps f  


**************** Tests for Differences **********************
**bookprice row
qui reghdfe bookprice treatedjuris if presample==1 , absorb(i.obsym) cluster(taxjuris)

est store C1 

qui reghdfe bookprice treatedjuris $controls if presample==1 , ///
absorb(i.metro1#i.obsym) cluster(taxjuris)

est store C2

esttab C1 C2 using TableD1_tests.tex, replace ///
star(* 0.10 ** 0.05 *** 0.01) ///
cells("b(fmt(3)star)" "se(fmt(3)par)") keep(treatedjuris) coef(treatedjuris "Booking Price") ///
width(\hsize) nomtitles label booktabs alignment(S) nonum collabels(none) gaps noobs f 


** lnbookprice row
qui reghdfe lnbookprice treatedjuris if presample==1 , absorb(i.obsym) cluster(taxjuris)

est store C1 

qui reghdfe lnbookprice treatedjuris $controls if presample==1  , ///
absorb(i.metro1#i.obsym) cluster(taxjuris)

est store C2

esttab C1 C2 using TableD1_tests.tex, append ///
star(* 0.10 ** 0.05 *** 0.01) ///
cells("b(fmt(3)star)" "se(fmt(3)par)") keep(treatedjuris) coef(treatedjuris "Ln(Booking Price)") ///
width(\hsize) nomtitles label booktabs alignment(S) nonum collabels(none) gaps noobs f 



** booked row
qui reghdfe booked treatedjuris if presample==1 , absorb(i.obsym) cluster(taxjuris)

est store C1 

qui reghdfe booked treatedjuris $controls if presample==1 , ///
absorb(i.metro1#i.obsym) cluster(taxjuris)

est store C2

esttab C1 C2 using TableD1_tests.tex, append ///
star(* 0.10 ** 0.05 *** 0.01) ///
cells("b(fmt(3)star)" "se(fmt(3)par)") keep(treatedjuris) coef(treatedjuris "Days Booked / Month") ///
width(\hsize) nomtitles label booktabs alignment(S) nonum collabels(none) gaps noobs f 



** lnbooked row
qui reghdfe lnbooked treatedjuris if presample==1 , absorb(i.obsym) cluster(taxjuris)

est store C1 

qui reghdfe lnbooked treatedjuris $controls if presample==1  , ///
absorb(i.metro1#i.obsym) cluster(taxjuris)

est store C2

esttab C1 C2 using TableD1_tests.tex, append ///
star(* 0.10 ** 0.05 *** 0.01) ///
cells("b(fmt(3)star)" "se(fmt(3)par)") keep(treatedjuris) coef(treatedjuris "Ln(Days Booked)") ///
width(\hsize) nomtitles label booktabs alignment(S) nonum collabels(none) gaps noobs f 


** asking price row
qui reghdfe askingprice treatedjuris if presample==1 , absorb(i.obsym) cluster(taxjuris)

est store C1 

qui reghdfe askingprice treatedjuris $controls if presample==1  , ///
absorb(i.metro1#i.obsym) cluster(taxjuris)

est store C2

esttab C1 C2 using TableD1_tests.tex, append ///
star(* 0.10 ** 0.05 *** 0.01) ///
cells("b(fmt(3)star)" "se(fmt(3)par)") keep(treatedjuris) coef(treatedjuris "Asking Price") ///
width(\hsize) nomtitles label booktabs alignment(S) nonum collabels(none) gaps noobs f 


** ln asking price row
qui reghdfe lnaskingprice treatedjuris if presample==1 , absorb(i.obsym) cluster(taxjuris)

est store C1 

qui reghdfe lnaskingprice treatedjuris $controls if presample==1 , ///
absorb(i.metro1#i.obsym) cluster(taxjuris)

est store C2

esttab C1 C2 using TableD1_tests.tex, append ///
star(* 0.10 ** 0.05 *** 0.01) ///
cells("b(fmt(3)star)" "se(fmt(3)par)") keep(treatedjuris) coef(treatedjuris "Ln(Asking Price)") ///
width(\hsize) nomtitles label booktabs alignment(S) nonum collabels(none) gaps noobs f 



qui reg booked supply 

estadd local monthyrfe = "\checkmark"
estadd local metromonthyrfe = "-"
estadd local propcontrols = "-"

est store C1

qui reghdfe treatedjuris $controls if presample==1 , ///
absorb(i.metro1#i.obsym) cluster(taxjuris)

estadd local monthyrfe = "-"
estadd local metromonthyrfe = "\checkmark"
estadd local propcontrols = "\checkmark"

est store C2

esttab C1 C2 using TableD1_tests.tex, append ///
label booktabs alignment(S) nonum nomtitles collabels(none) gaps noobs f  cells(none) ///
stats(monthyrfe metromonthyrfe propcontrols , fmt(%9.2fc %1s %1s %1s) ///
layout("\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}") ///
 labels(`"Month-Year FE"' `"Metro-Month-Year FE"' `"Property Level Controls"')) 

 

**************
** TABLE D2 **
**************
 
** jurisdiction level characteristics and tests
use propmonth_analysis_restricted.dta , clear

drop if regexm(metro, ".*Anchorage") 
drop if regexm(metro, ".*Atlanta")
drop if regexm(metro, ".*Austin")
drop if regexm(metro, ".*Boston")
drop if regexm(metro, ".*Charlotte")
drop if regexm(metro, ".*Dallas")
drop if regexm(metro, ".*Houston")
drop if regexm(metro, ".*Indianapolis")
drop if regexm(metro, ".*Minneapolis")
drop if regexm(metro, ".*Nashville")
drop if regexm(metro, ".*Philadelphia")

gen entirehome = regexm(listingtype , ".*Entire") 
replace numbookings=0 if missing(numbookings)

gen entrysample = 1
replace entrysample=0 if inlist(obsym,655,692)

bysort taxjuris obsym: egen numprops = count(propertyid)

bysort propertyid: egen lastsupply = max(obsym) if supply>0
bysort propertyid: egen lastsupply2 = min(lastsupply)
gen firstzero = lastsupply2 + 1
gen exit2 = 0
replace exit2 = 1 if obsym==lastsupply2 & lastsupply2!=692
replace exit2=. if obsym>lastsupply2 

gen posbook = (booked>0)

** AGGREGATE TO THE JURISDICTION MONTH LEVEL

collapse (mean) taxvar mnposbook=posbook (sum) numprops=obs booked supply (median) medaskprice=askingprice medbookprice=bookprice ///
		(p25) askpricep25=askingprice bookpricep25=bookprice (p75) askpricep75=askingprice bookpricep75=bookprice, by(taxjuris metro1 obsym)

xtset taxjuris obsym

gen taxdummy = taxvar>0 & !missing(taxvar)

gen propbooked = booked/supply

sort taxjuris obsym

bysort taxjuris: gen pctchnumprops = ((numprops - L.numprops)/L.numprops)
bysort taxjuris: gen pctchsupply = ((supply - L.supply)/L.supply)
bysort taxjuris: gen pctchbooked = ((booked - L.booked)/L.booked)
bysort taxjuris: gen chmnposbook = mnposbook - L.mnposbook
gen pctchmedbook = ((medbookprice - L.medbookprice)/L.medbookprice)
gen pctchbookp25 = ((bookpricep25 - L.bookpricep25)/L.bookpricep25)
gen pctchbookp75 = ((bookpricep75 - L.bookpricep75)/L.bookpricep75)


*****************************************************************************
*********** STARTING FROM TABLE 2 WITH PROP LEVEL DIFFERENCES  **************
*****************************************************************************

gen treatedmonth = taxvar>0
bysort taxjuris: egen treatedjuris = max(treatedmonth) 
bysort taxjuris: egen firsttaxmonth2 = min(obsym) if treatedmonth==1
bysort taxjuris: egen firsttaxmonth = min(firsttaxmonth2)
bysort taxjuris: egen mntaxvar2 = mean(taxvar) if treatedmonth==1
bysort taxjuris: egen mntaxvar = max(mntaxvar2)
drop firsttaxmonth2 mntaxvar2


*********************************************************************************
*********** averages and testing differences in averages ************************
*********************************************************************************
bysort metro1: egen firsttaxmetro = min(obsym) if taxvar>0 
bysort metro1: egen firsttaxmetro2 = min(firsttaxmetro)
bysort metro1: egen mintreat = min(treatedjuris)

local sstats "numprops supply booked mnposbook medbookprice bookpricep25 bookpricep75 pctchnumprops pctchsupply pctchbooked chmnposbook pctchmedbook pctchbookp25 pctchbookp75"

reg `sstats' if (treatedmonth==0 & obsym>655 & obsym<688)
gen presample = e(sample)

reg `sstats' if (treatedmonth==0 & obsym>655 & obsym<firsttaxmetro2)
gen presample2 = e(sample) 

keep if presample2==1

lab var numprops "Number of Properties"
lab var supply "Total Nights Available"
lab var booked "Total Nights Booked"
lab var mnposbook "Proportion Props Booked"
lab var medbookprice "Median Book Price"
lab var bookpricep25 "Book Price 25th Pctile"
lab var bookpricep75 "Book Price 75th Pctile"
lab var pctchnumprops "Pct. Change Num Props"
lab var pctchsupply "Pct. Change Nights Avail"
lab var pctchbooked "Pct. Change Total Nights Booked"
lab var chmnposbook "Change Prop. Props Booked"
lab var pctchmedbook "Pct. Change Med. Book Price"
lab var pctchbookp25 "Pct. Change Book Price 25th Pct."
lab var pctchbookp75 "Pct. Change Book Price 75th Pct."

** Table D2, Columns 1-3
** full sample
estpost su `sstats' 
est store C1 

** eventually treated sample
estpost su `sstats' if treatedjuris==1
est store C2

estpost su `sstats' if treatedjuris==0
est store C3

esttab C1 C2 C3 using TableD2_summary.tex, replace ///
mtitles("Full Sample" "Treated" "Not Treated") ///
cells(mean(fmt(2)) sd(fmt(2)par)) label booktabs nonum collabels(none) gaps f  


**************** Tests for Differences **********************
** Table D2, Clumns 4-5
**numberof props
qui reghdfe numprops treatedjuris , absorb(i.obsym) cluster(taxjuris)
est store C1 

qui reghdfe numprops treatedjuris , absorb(i.metro1#i.obsym) cluster(taxjuris)
est store C2

esttab C1 C2 using TableD2_tests.tex, replace ///
mtitles("Treated - Not Treated") ///
star(* 0.10 ** 0.05 *** 0.01) ///
cells("b(fmt(3)star)" "se(fmt(3)par)") keep(treatedjuris) coef(treatedjuris "Number of Properties") ///
width(\hsize)  label booktabs alignment(S) nonum collabels(none) gaps noobs f 

local sstats "supply booked mnposbook medbookprice bookpricep25 bookpricep75 pctchnumprops pctchsupply pctchbooked chmnposbook pctchmedbook pctchbookp25 pctchbookp75"

foreach x in `sstats' {

**Pct Ch number of properties
qui reghdfe `x' treatedjuris if presample2==1 , absorb(i.obsym) cluster(taxjuris)
est store C1 
outreg2 using TableD2_tests.xls , excel lab keep(treatedjuris) ct("`x'") append

qui reghdfe `x' treatedjuris if presample2==1 , absorb(i.metro1#i.obsym) cluster(taxjuris)
est store C2
outreg2 using TableD2_tests.xls , excel lab keep(treatedjuris) ct("`x'") append

esttab C1 C2 using TableD2_tests.tex, append ///
star(* 0.10 ** 0.05 *** 0.01) ///
cells("b(fmt(3)star)" "se(fmt(3)par)") keep(treatedjuris) coef(treatedjuris "`x'") ///
width(\hsize) label booktabs alignment(S) nomtitles nonum collabels(none) gaps noobs f plain

}


 
************** 
** Table D3 **
**************
** Robustness Checks
use "propmonth_analysis_restricted - alternate property restrictions.dta", clear

drop if regexm(metro, ".*Anchorage") 
drop if regexm(metro, ".*Atlanta")
drop if regexm(metro, ".*Austin")
drop if regexm(metro, ".*Boston")
drop if regexm(metro, ".*Charlotte")
drop if regexm(metro, ".*Dallas")
drop if regexm(metro, ".*Houston")
drop if regexm(metro, ".*Indianapolis")
drop if regexm(metro, ".*Minneapolis")
drop if regexm(metro, ".*Nashville")
drop if regexm(metro, ".*Philadelphia")

********************************************************************************
******* 		Results: Booking Price and Number Booked 		   *************
*******         No Property Restrictions						   *************
********************************************************************************

set more off
set matsize 1000

* Column 1
qui reghdfe lnbookprice lntaxvar [w=booked] , absorb(propertyid i.metro1#i.obsym) cluster(taxjuris)
outreg2 using TableD3A, excel auto(3) stats(coef se) adds(N, e(N_clust)) keep(lntaxvar) replace

qui reghdfe lnbooked lntaxvar , absorb(propertyid i.metro1#i.obsym) cluster(taxjuris)
outreg2 using TableD3B, excel auto(3) stats(coef se) adds(N, e(N_clust)) keep(lntaxvar) replace


********************************************************************************
******* 		Results: Booking Price and Number Booked 		   *************
*******         5/95 and 25/75, No Shared Room, <=4 bed, <=12 guests ***********
********************************************************************************
* columns 2-3
foreach x in 595 2575 {

qui reghdfe lnbookprice lntaxvar [w=booked] if askprice`x'==1 & sharedroom==0 & bedroomsleq4==1 & maxguestsleq12==1, absorb(propertyid i.metro1#i.obsym) cluster(taxjuris)
outreg2 using TableD3A, excel auto(3) stats(coef se) adds(N, e(N_clust)) keep(lntaxvar) append

qui reghdfe lnbooked lntaxvar if askprice`x'==1 & sharedroom==0 & bedroomsleq4==1 & maxguestsleq12==1 , absorb(propertyid i.metro1#i.obsym) cluster(taxjuris)
outreg2 using TableD3B, excel auto(3) stats(coef se) adds(N, e(N_clust)) keep(lntaxvar) append


}

 
** Columns 4-7

use "propmonth_analysis_restricted.dta", clear

drop if regexm(metro, ".*Anchorage") 
drop if regexm(metro, ".*Atlanta")
drop if regexm(metro, ".*Austin")
drop if regexm(metro, ".*Boston")
drop if regexm(metro, ".*Charlotte")
drop if regexm(metro, ".*Dallas")
drop if regexm(metro, ".*Houston")
drop if regexm(metro, ".*Indianapolis")
drop if regexm(metro, ".*Minneapolis")
drop if regexm(metro, ".*Nashville")
drop if regexm(metro, ".*Philadelphia")


** Panel A, Column 4, Unweighted price estimates

qui reghdfe lnbookprice lntaxvar , absorb(propertyid i.metro1#i.obsym) cluster(taxjuris)
outreg2 using TableD3A, excel auto(3) stats(coef se) adds(N, e(N_clust)) keep(lntaxvar) append


** Panel B, Column 5, placed that booked at some point 

bysort propertyid: egen totalbooked = sum(booked) 
gen posbook = totalbooked>0
qui reghdfe lnbooked lntaxvar if posbook==1 , absorb(propertyid i.metro1#i.obsym) cluster(taxjuris)
outreg2 using TableD3B, excel auto(3) stats(coef se) adds(N, e(N_clust)) keep(lntaxvar) append


** last two columns
**** removing first month of tax (and maybe month before tax)

gen treatedmonth = taxvar>0
bysort taxjuris: egen treatedjuris = max(treatedmonth) 

gen omitfirst_sample = 1
replace omitfirst_sample=0 if ( taxintro==obsym & treatedjuris==1 )

gen omittwo_sample = omitfirst_sample
replace omittwo_sample = 0 if ( (obsym + 1) == taxintro & treatedjuris==1) 


** bookings, omit first month of tax
qui reghdfe lnbooked lntaxvar if omitfirst_sample==1 , absorb(propertyid i.metro1#i.obsym) cluster(taxjuris)
outreg2 using TableD3B, excel auto(3) stats(coef se) adds(N, e(N_clust)) keep(lntaxvar) append

** bookings, omit the month before and first month of tax
qui reghdfe lnbooked lntaxvar if omittwo_sample==1 , absorb(propertyid i.metro1#i.obsym) cluster(taxjuris)
outreg2 using TableD3B, excel auto(3) stats(coef se) adds(N, e(N_clust)) keep(lntaxvar) append


** price, omit first month of tax
qui reghdfe lnbookprice lntaxvar if omitfirst_sample==1 [w=booked] , absorb(propertyid i.metro1#i.obsym) cluster(taxjuris)
outreg2 using TableD3A, excel auto(3) stats(coef se) adds(N, e(N_clust)) keep(lntaxvar) append

** price, omit first month of tax and last month prior
qui reghdfe lnbookprice lntaxvar if omittwo_sample==1 [w=booked] , absorb(propertyid i.metro1#i.obsym) cluster(taxjuris)
outreg2 using TableD3A, excel auto(3) stats(coef se) adds(N, e(N_clust)) keep(lntaxvar) append
 
 
 
 
 
 
************** 
** Table D4 **
**************
** Omitting jurisdictions with ambiguous tax obligations
use "propmonth_analysis_excl_unclear_tax_oblig.dta" , clear

drop if regexm(metro, ".*Anchorage") 
drop if regexm(metro, ".*Atlanta")
drop if regexm(metro, ".*Austin")
drop if regexm(metro, ".*Boston")
drop if regexm(metro, ".*Charlotte")
drop if regexm(metro, ".*Dallas")
drop if regexm(metro, ".*Houston")
drop if regexm(metro, ".*Indianapolis")
drop if regexm(metro, ".*Minneapolis")
drop if regexm(metro, ".*Nashville")
drop if regexm(metro, ".*Philadelphia")
	
gen entirehome = regexm(listingtype, ".*Entire")   

global controls "i.rated#c.rating1 i.rated#c.rating1sq securitydeposit securitydepositsq cleaningfee cleaningfeesq extrapeoplefee extrapeoplefeesq i.minimumstay1 i.hasphotos#c.photos1 i.hasphotos#c.photos1sq i.businessready_dum i.superhost1"

** Panel A (ln of booking price)
qui reghdfe lnbookprice lntaxvar [w=booked] , absorb(propertyid i.metro1#i.obsym) cluster(taxjuris)
outreg2 using TableD4A.xls , excel keep(lntaxvar) ct("ln(Booking Price)") replace

qui reghdfe lnbookprice lntaxvar [w=booked] , absorb(propertyid i.countyid#i.obsym) cluster(taxjuris)
outreg2 using TableD4A.xls , excel keep(lntaxvar) ct("ln(Booking Price)") append

qui reghdfe lnbookprice lntaxvar [w=booked] , absorb(propertyid i.obsym) cluster(taxjuris)
outreg2 using TableD4A.xls , excel keep(lntaxvar) ct("ln(Booking Price)") append

qui reghdfe lnbookprice lntaxvar $controls [w=booked] , absorb(taxjuris i.metro1#i.obsym i.bedrooms i.bathrooms1 i.maxguests1 i.entirehome i.cancel) cluster(taxjuris)
outreg2 using TableD4A.xls , excel keep(lntaxvar) ct("ln(Booking Price)") append

qui reghdfe lnbookprice lntaxvar $controls [w=booked] , absorb(taxjuris i.countyid#i.obsym i.bedrooms i.bathrooms1 i.maxguests1 i.entirehome i.cancel) cluster(taxjuris)
outreg2 using TableD4A.xls , excel keep(lntaxvar) ct("ln(Booking Price)") append

qui reghdfe lnbookprice lntaxvar $controls [w=booked] , absorb(taxjuris i.obsym i.bedrooms i.bathrooms1 i.maxguests1 i.entirehome i.cancel) cluster(taxjuris)
outreg2 using TableD4A.xls , excel keep(lntaxvar) ct("ln(Booking Price)") append

** Panel B, Log of bookings
qui reghdfe lnbooked lntaxvar , absorb(propertyid i.metro1#i.obsym) cluster(taxjuris)
outreg2 using TableD4B.xls , excel keep(lntaxvar) ct("ln(1 + Nights Booked)") replace

qui reghdfe lnbooked lntaxvar , absorb(propertyid i.countyid#i.obsym) cluster(taxjuris)
outreg2 using TableD4B.xls , excel keep(lntaxvar) ct("ln(1 + Nights Booked)") append

qui reghdfe lnbooked lntaxvar , absorb(propertyid i.obsym) cluster(taxjuris)
outreg2 using TableD4B.xls , excel keep(lntaxvar) ct("ln(1 + Nights Booked)") append

qui reghdfe lnbooked lntaxvar $controls , absorb(taxjuris i.metro1#i.obsym i.bedrooms i.bathrooms1 i.maxguests1 i.entirehome i.cancel) cluster(taxjuris)
outreg2 using TableD4B.xls , excel keep(lntaxvar) ct("ln(1 + Nights Booked)") append

qui reghdfe lnbooked lntaxvar $controls , absorb(taxjuris i.countyid#i.obsym i.bedrooms i.bathrooms1 i.maxguests1 i.entirehome i.cancel) cluster(taxjuris)
outreg2 using TableD4B.xls , excel keep(lntaxvar) ct("ln(1 + Nights Booked)") append

qui reghdfe lnbooked lntaxvar $controls , absorb(taxjuris i.obsym i.bedrooms i.bathrooms1 i.maxguests1 i.entirehome i.cancel) cluster(taxjuris)
outreg2 using TableD4B.xls , excel keep(lntaxvar) ct("ln(1 + Nights Booked)") append

* reset global for controls
global controls "i.bedrooms i.bathrooms1 i.maxguests1 entirehome i.rated#c.rating1 i.rated#c.rating1sq securitydeposit securitydepositsq cleaningfee cleaningfeesq extrapeoplefee extrapeoplefeesq i.cancel i.minimumstay1 i.hasphotos#c.photos1 i.hasphotos#c.photos1sq i.businessready_dum i.superhost1"

************** 
** TABLE D5 **
**************
** Only include largest juris in each metro
 
use propmonth_analysis_restricted.dta , clear

gen mainsample=1 

replace mainsample=0 if regexm(metro, ".*Anchorage") 
replace mainsample=0 if regexm(metro, ".*Atlanta")
replace mainsample=0 if regexm(metro, ".*Austin")
replace mainsample=0 if regexm(metro, ".*Boston")
replace mainsample=0 if regexm(metro, ".*Charlotte")
replace mainsample=0 if regexm(metro, ".*Dallas")
replace mainsample=0 if regexm(metro, ".*Houston")
replace mainsample=0 if regexm(metro, ".*Indianapolis")
replace mainsample=0 if regexm(metro, ".*Minneapolis")
replace mainsample=0 if regexm(metro, ".*Nashville")
replace mainsample=0 if regexm(metro, ".*Philadelphia")

gen treatedmonth = taxvar>0

** treated jurisdiction dummy
bysort taxjuris: egen treatedjuris = max(treatedmonth) 

** treated number of obs in juris
bysort taxjuris: egen jurisobs = sum(obs)

** pick out one obs for each juris
bysort taxjuris: gen firstobs = _n==1 

** pick largest jurisdiction, largest treated and not treated in each metro
bysort metro: egen metrorank = rank(1/jurisobs) if firstobs==1

bysort metro treatedjuris: egen mettreatrank = rank(1/jurisobs) if firstobs==1

** assign appropriate ranks to the rest of the obs
bysort taxjuris: egen metrorank2 = min(metrorank)

reghdfe lnbookprice lntaxvar [w=booked] if (metrorank2==1 & mainsample==1) , absorb(propertyid i.obsym) cluster(taxjuris)
outreg2 using TableD5.xls , excel keep(lntaxvar) ct("ln(Booking Price)") replace

reghdfe lnbooked lntaxvar if (metrorank2==1 & mainsample==1) , absorb(propertyid i.obsym) cluster(taxjuris)
outreg2 using TableD5.xls , excel keep(lntaxvar) ct("ln(1 + Nights Booked)") append

reghdfe lnbookprice lntaxvar [w=booked] if (metrorank2==1) , absorb(propertyid i.obsym) cluster(taxjuris)
outreg2 using TableD5.xls , excel keep(lntaxvar) ct("ln(Booking Price)") append

reghdfe lnbooked lntaxvar if (metrorank2==1) , absorb(propertyid i.obsym) cluster(taxjuris)
outreg2 using TableD5.xls , excel keep(lntaxvar) ct("ln(1 + Nights Booked)") append
 


 
  
**************
** Table D6 **
**************
********************************************************************************
******* 		Results: Booking Price and Number Booked 		   *************
*******         No Price Restriction, By listingtype    		   *************
********************************************************************************

use "propmonth_analysis_restricted - alternate property restrictions - no shared room.dta", clear

drop if regexm(metro, ".*Anchorage") 
drop if regexm(metro, ".*Atlanta")
drop if regexm(metro, ".*Austin")
drop if regexm(metro, ".*Boston")
drop if regexm(metro, ".*Charlotte")
drop if regexm(metro, ".*Dallas")
drop if regexm(metro, ".*Houston")
drop if regexm(metro, ".*Indianapolis")
drop if regexm(metro, ".*Minneapolis")
drop if regexm(metro, ".*Nashville")
drop if regexm(metro, ".*Philadelphia")

** Columns 1-2
qui reghdfe lnbookprice lntaxvar [w=booked] if entirehome==1, absorb(propertyid i.metro1#i.obsym) cluster(taxjuris)
outreg2 using TableD6A, excel auto(3) stats(coef se) adds(N, e(N_clust)) keep(lntaxvar) replace

qui reghdfe lnbooked lntaxvar if entirehome==1 , absorb(propertyid i.metro1#i.obsym) cluster(taxjuris)
outreg2 using TableD6B, excel auto(3) stats(coef se) adds(N, e(N_clust)) keep(lntaxvar) replace


qui reghdfe lnbookprice lntaxvar [w=booked] if privateroom==1, absorb(propertyid i.metro1#i.obsym) cluster(taxjuris)
outreg2 using TableD6A, excel auto(3) stats(coef se) adds(N, e(N_clust)) keep(lntaxvar) append

qui reghdfe lnbooked lntaxvar if privateroom==1 , absorb(propertyid i.metro1#i.obsym) cluster(taxjuris)
outreg2 using TableD6B, excel auto(3) stats(coef se) adds(N, e(N_clust)) keep(lntaxvar) append


********************************************************************************
******* 		Results: Booking Price and Number Booked 		   *************
*******         Quartiles of Prices, only private and entire   	   *************
********************************************************************************

** Table D6, Columns 3-6

foreach x in quartile1 quartile2 quartile3 quartile4 {

qui reghdfe lnbookprice lntaxvar [w=booked] if askprice_`x'==1, absorb(propertyid i.metro1#i.obsym) cluster(taxjuris)
outreg2 using TableD6A, excel auto(3) stats(coef se) adds(N, e(N_clust)) keep(lntaxvar) append

qui reghdfe lnbooked lntaxvar if askprice_`x'==1 , absorb(propertyid i.metro1#i.obsym) cluster(taxjuris)
outreg2 using TableD6B, excel auto(3) stats(coef se) adds(N, e(N_clust)) keep(lntaxvar) append

 }  
   